|
Displaying DB fields with the help of the "Text" object As you can see, the "Text" object is able to display data from DB, in addition to displaying static text and expressions. Moreover, we can do it in two ways: by either placing a link to the DB field into the object text, or connecting an object to the required field with the help of the "DataSet" and "DataField" properties. The first way is rather good in terms of possibility to display both field contents and any explanatory statement in one and the same object. For example: Contact person: [frxDBDataSet1."Contact_Person"] As you can see, special syntax is used for links to the DB field: data_set_name. "field_name." The field name (as well as the set name) can contain spaces. Space between the "point" and "quote" symbols is not permitted. Not only a link to a field can be placed in the text of the object. We can apply different computing operations to a field as well: Length (cm): [<frxDBDataSet1."Length_in"> * 2.54] Pay attention to how square and angle brackets have been used. Remember that square brackets are used by default for to marking out the expressions, which are included in the object text. In case of need, square brackets can be substituted for a pair of any other opening/closing sequences (see the "Displaying expression with the help of the "Text" object" section). Angular brackets are used inside expressions for marking out the FastReport variables and DB fields. To be logical, we should write Contact person: [<frxDBDataSet1."Contact_Person">] instead of Contact person: [frxDBDataSet1."Contact_Person"] Nevertheless, both these notations are correct, since FastReport allows absence of angular brackets, in case when an expression contains only one variable or only one DB field. However, if an expression contains several members, the brackets are obligatory: Length (cm): [<frxDBDataSet1."Length_in"> * 2.54] This is one of the essential distinctions from the earlier FastReport versions, where square brackets are mostly used (instead of angle ones). This was made due to the fact that all expressions are processed with the script language, where square brackets are used for marking out either sets or open arrays. |